//正则验证不能为空
const storage = require('./cache.js')
const isEmpty = (str) => {
  let reg = /^\s*$/g;
  if (reg.test(str) || str == null || str == "")
    return true
}

//成功提示
const showSuccess = text => wx.showToast({
  title: text,
  icon: 'success',
  duration: 1500
})

//纯文字提示
const showFail = text => wx.showToast({
  title: text,
  icon: 'none',
  duration: 1500
})

//验证 openid
const checkOpenid = () => {
  var promise = new Promise((resolve, reject) => {
    storage.get('openid').then(res => {
      if (res.errMsg === "getStorage:ok") {
        resolve('true')
      }else{
        resolve('false')
      }
    })
  });
  return promise;
}
module.exports = {
  isEmpty,
  showSuccess,
  showFail,
  checkOpenid
}
